package aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class Aspectj {
	//前置通知
	public void myBefore(JoinPoint joinPoint) {
		System.out.println("开启事务");
	}
	//后置通知
	public void myAfterReturning(JoinPoint joinPoint) {
		System.out.println("结束事务");
	}
	public Object myAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
		//开始
		System.out.println("环绕开启事务");
		//执行当前目标方法
		Object obj = proceedingJoinPoint.proceed();
		//结束
		System.out.println("环绕结束事务");
		return obj;
	}
	//异常通知
	public void myAfterThrowing(JoinPoint joinPoint,Throwable e) {
		System.out.println("异常通知:"+"出错了"+e.getMessage());
		System.out.println("进行回滚操作");
	}
}
